home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DELPHI / DIRECTX.ZIP / DSOUND.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-01-24  |  9.4 KB  |  259 lines

  1. unit dsound ;
  2.  
  3. interface
  4.  
  5. uses OLE2, Windows, MMSystem ;
  6.  
  7. {*==========================================================================;
  8.  *
  9.  *  Copyright (C) 1995 Microsoft Corporation.  All Rights Reserved.
  10.  *
  11.  *  Conversion (version 0.8) to Delphi 2.0 by Blake Stone
  12.  *
  13.  *    email:     bstone@dkw.com
  14.  *    home page: http://www.dkw.com/bstone
  15.  *
  16.  *  File:       dsound.h
  17.  *  Content:    DirectSound include file
  18.  *
  19.  *=========================================================================}
  20.  
  21. { The following are included, untranslated from the C declaration,
  22.   for informational purposes only }
  23.  
  24. (*
  25. #define _FACDS  0x878
  26. #define MAKE_DSHRESULT( code )  MAKE_HRESULT( 1, _FACDS, code )
  27.  
  28. // DirectSound 279afa83-4981-11ce-a521-0020af0be560
  29. DEFINE_GUID(IID_IDirectSound,0x279AFA83,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
  30. // DirectSoundBuffer 279afa85-4981-11ce-a521-0020af0be560
  31. DEFINE_GUID(IID_IDirectSoundBuffer,0x279AFA85,0x4981,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60);
  32. *)
  33.  
  34. { Structures }
  35.  
  36. type
  37.   IDirectSound = class ;
  38.   IDirectSoundBuffer = class ;
  39.  
  40.   LPDSCAPS = ^DSCAPS ;
  41.   DSCAPS = record
  42.     dwSize: DWORD ;
  43.     dwFlags: DWORD ;
  44.     dwMinSecondarySampleRate: DWORD ;
  45.     dwMaxSecondarySampleRate: DWORD ;
  46.     dwPrimaryBuffers: DWORD ;
  47.     dwMaxHwMixingAllBuffers: DWORD ;
  48.     dwMaxHwMixingStaticBuffers: DWORD ;
  49.     dwMaxHwMixingStreamingBuffers: DWORD ;
  50.     dwFreeHwMixingAllBuffers: DWORD ;
  51.     dwFreeHwMixingStaticBuffers: DWORD ;
  52.     dwFreeHwMixingStreamingBuffers: DWORD ;
  53.     dwMaxHw3DAllBuffers: DWORD ;
  54.     dwMaxHw3DStaticBuffers: DWORD ;
  55.     dwMaxHw3DStreamingBuffers: DWORD ;
  56.     dwFreeHw3DAllBuffers: DWORD ;
  57.     dwFreeHw3DStaticBuffers: DWORD ;
  58.     dwFreeHw3DStreamingBuffers: DWORD ;
  59.     dwTotalHwMemBytes: DWORD ;
  60.     dwFreeHwMemBytes: DWORD ;
  61.     dwMaxContigFreeHwMemBytes: DWORD ;
  62.     dwUnlockTransferRateHwBuffers: DWORD ;
  63.     dwPlayCpuOverheadSwBuffers: DWORD ;
  64.     dwReserved1: DWORD ;
  65.     dwReserved2: DWORD ;
  66.   end ;
  67.  
  68.   LPDSBCAPS = ^DSBCAPS ;
  69.   DSBCAPS = record
  70.     dwSize: DWORD ;
  71.     dwFlags: DWORD ;
  72.     dwBufferBytes: DWORD ;
  73.     dwUnlockTransferRate: DWORD ;
  74.     dwPlayCpuOverhead: DWORD ;
  75.   end ;
  76.  
  77.   LPDSBUFFERDESC = ^DSBUFFERDESC ;
  78.   DSBUFFERDESC = record
  79.     dwSize: DWORD ;
  80.     dwFlags: DWORD ;
  81.     dwBufferBytes: DWORD ;
  82.     dwReserved: DWORD ;
  83.     lpwfxFormat: PWaveFormatEx ;
  84.   end ;
  85.  
  86.   LPDSENUMCALLBACK = function ( lpGUID: PGUID; lpstrDescription: PChar;
  87.       lpstrModule: PChar; lpContext: Pointer ): BOOL ;
  88.  
  89. { IDirectSound }
  90.  
  91.   IDirectSound = class ( IUnknown )
  92.     function CreateSoundBuffer ( const lpDSBufferDesc: DSBUFFERDESC ;
  93.         var lplpDirectSoundBuffer: IDirectSoundBuffer ;
  94.         pUnkOuter: IUnknown ): HRESULT ; virtual ; stdcall ; abstract ;
  95.     function GetCaps ( var lpDSCaps: DSCAPS ): HRESULT ;
  96.         virtual ; stdcall ; abstract ;
  97.     function DuplicateSoundBuffer ( lpDsbOriginal: IDirectSoundBuffer ;
  98.         var lplpDsbDuplicate: IDirectSoundBuffer ): HRESULT ;
  99.         virtual ; stdcall ; abstract ;
  100.     function SetCooperativeLevel ( hwnd: HWND ; dwLevel: DWORD ): HRESULT ;
  101.         virtual ; stdcall ; abstract ;
  102.     function Compact: HRESULT ; virtual ; stdcall ; abstract ;
  103.     function GetSpeakerConfig ( var lpdwSpeakerConfig: DWORD ): HRESULT ;
  104.         virtual ; stdcall ; abstract ;
  105.     function SetSpeakerConfig ( dwSpeakerConfig: DWORD ): HRESULT ;
  106.         virtual ; stdcall ; abstract ;
  107.     function Initialize ( lpGuid: PGUID ): HRESULT ; virtual ; stdcall ; abstract ;
  108.   end ;
  109.  
  110. { IDirectSoundBuffer }
  111.  
  112.   IDirectSoundBuffer = class ( IUnknown )
  113.     function GetCaps ( var lpDSBufferCaps: DSBCAPS ): HRESULT ;
  114.         virtual ; stdcall ; abstract ;
  115.     function GetCurrentPosition ( var lpdwCurrentPlayCursor: DWORD ;
  116.         var lpdwCurrentWriteCursor: DWORD ): HRESULT ;
  117.         virtual ; stdcall ; abstract ;
  118.     function GetFormat ( var lpwfxFormat: TWaveFormatEx ; dwSizeAllocated: DWORD ;
  119.         var lpdwSizeWritten: DWORD ): HRESULT ; virtual ; stdcall ; abstract ;
  120.     function GetVolume ( var lplVolume: LongInt ): HRESULT ;
  121.         virtual ; stdcall ; abstract ;
  122.     function GetPan ( var lplPan: LongInt ): HRESULT ;
  123.         virtual ; stdcall ; abstract ;
  124.     function GetFrequency ( var lpdwFrequency: DWORD ): HRESULT ;
  125.         virtual ; stdcall ; abstract ;
  126.     function GetStatus ( var lpdwStatus: DWORD ): HRESULT ;
  127.         virtual ; stdcall ; abstract ;
  128.     function Initialize ( lpDirectSound: IDirectSound ;
  129.         const lpDSBufferDesc: DSBUFFERDESC ): HRESULT ;
  130.         virtual ; stdcall ; abstract ;
  131.     function Lock ( dwWriteCursor: DWORD ; dwWriteBytes: DWORD ;
  132.         var lplpvAudioPtr1: Pointer ; var lpdwAudioBytes1: DWORD ;
  133.         var lplpvAudioPtr2: Pointer ; var lpdwAudioBytes2: DWORD ;
  134.         dwFlags: DWORD ): HRESULT ; virtual ; stdcall ; abstract ;
  135.     function Play ( dwReserved1: DWORD ; dwReserved2: DWORD ;
  136.         dwFlags: DWORD ): HRESULT ; virtual ; stdcall ; abstract ;
  137.     function SetCurrentPosition ( dwNewPosition: DWORD ): HRESULT ;
  138.         virtual ; stdcall ; abstract ;
  139.     function SetFormat ( const lpwfxFormat: TWaveFormatEx ): HRESULT ;
  140.         virtual ; stdcall ; abstract ;
  141.     function SetVolume ( lVolume: LongInt ): HRESULT ;
  142.         virtual ; stdcall ; abstract ;
  143.     function SetPan ( lPan: LongInt ): HRESULT ; virtual ; stdcall ; abstract ;
  144.     function SetFrequency ( dwFrequency: DWORD ): HRESULT ;
  145.         virtual ; stdcall ; abstract ;
  146.     function Stop: HRESULT ; virtual ; stdcall ; abstract ;
  147.     function Unlock ( lpvAudioPtr1: Pointer ; dwAudioBytes1: DWORD ;
  148.         lpvAudioPtr2:Pointer ; dwAudioBytes2: DWORD ): HRESULT ;
  149.         virtual ; stdcall ; abstract ;
  150.     function Restore: HRESULT ; virtual ; stdcall ; abstract ;
  151.   end ;
  152.  
  153. { Return Codes }
  154.  
  155. const
  156.   DS_OK                           = 0 ;
  157.  
  158. { The call failed because resources (such as a priority level)
  159.   were already being used by another caller. }
  160.   DSERR_ALLOCATED                 = $88780000 + 10 ;
  161.  
  162. { The control (vol,pan,etc.) requested by the caller is not available. }
  163.   DSERR_CONTROLUNAVAIL            = $88780000 + 30 ;
  164.  
  165. { An invalid parameter was passed to the returning function }
  166.   DSERR_INVALIDPARAM              = E_INVALIDARG ;
  167.  
  168. { This call is not valid for the current state of this object }
  169.   DSERR_INVALIDCALL               = $88780000 + 50 ;
  170.  
  171. { An undetermined error occured inside the DSound subsystem }
  172.   DSERR_GENERIC                   = E_FAIL ;
  173.  
  174. { The caller does not have the priority level required for the function to
  175.   succeed. }
  176.   DSERR_PRIOLEVELNEEDED           = $88780000 + 70 ;
  177.  
  178. { The DSound subsystem couldn't allocate sufficient memory to complete the
  179.   caller's request. }
  180.   DSERR_OUTOFMEMORY               = E_OUTOFMEMORY ;
  181.  
  182. { The specified WAVE format is not supported }
  183.   DSERR_BADFORMAT                 = $88780000 + 100 ;
  184.  
  185. { The function called is not supported at this time }
  186.   DSERR_UNSUPPORTED               = E_NOTIMPL ;
  187.  
  188. { No sound driver is available for use }
  189.   DSERR_NODRIVER                  = $88780000 + 120 ;
  190.  
  191. { This object is already initialized }
  192.   DSERR_ALREADYINITIALIZED        = $88780000 + 130 ;
  193.  
  194. { This object does not support aggregation }
  195.   DSERR_NOAGGREGATION             = CLASS_E_NOAGGREGATION ;
  196.  
  197. { The buffer memory has been lost, and must be Restored. }
  198.   DSERR_BUFFERLOST                = $88780000 + 150 ;
  199.  
  200. { Another app has a higher priority level, preventing this call from
  201.   succeeding. }
  202.   DSERR_OTHERAPPHASPRIO           = $88780000 + 160 ;
  203.  
  204. { Flags }
  205.  
  206.   DSCAPS_PRIMARYMONO          = $00000001 ;
  207.   DSCAPS_PRIMARYSTEREO        = $00000002 ;
  208.   DSCAPS_PRIMARY8BIT          = $00000004 ;
  209.   DSCAPS_PRIMARY16BIT         = $00000008 ;
  210.   DSCAPS_CONTINUOUSRATE       = $00000010 ;
  211.   DSCAPS_EMULDRIVER           = $00000020 ;
  212.   DSCAPS_CERTIFIED            = $00000040 ;
  213.   DSCAPS_SECONDARYMONO        = $00000100 ;
  214.   DSCAPS_SECONDARYSTEREO      = $00000200 ;
  215.   DSCAPS_SECONDARY8BIT        = $00000400 ;
  216.   DSCAPS_SECONDARY16BIT       = $00000800 ;
  217.  
  218.   DSBPLAY_LOOPING             = $00000001 ;
  219.  
  220.   DSBSTATUS_PLAYING           = $00000001 ;
  221.   DSBSTATUS_BUFFERLOST        = $00000002 ;
  222.   DSBSTATUS_LOOPING           = $00000004 ;
  223.  
  224.   DSBLOCK_FROMWRITECURSOR     = $00000001 ;
  225.  
  226.   DSSCL_NORMAL                = 1 ;
  227.   DSSCL_PRIORITY              = 2 ;
  228.   DSSCL_EXCLUSIVE             = 3 ;
  229.   DSSCL_WRITEPRIMARY          = 4 ;
  230.  
  231.   DSBCAPS_PRIMARYBUFFER       = $00000001 ;
  232.   DSBCAPS_STATIC              = $00000002 ;
  233.   DSBCAPS_LOCHARDWARE         = $00000004 ;
  234.   DSBCAPS_LOCSOFTWARE         = $00000008 ;
  235.   DSBCAPS_CTRLFREQUENCY       = $00000020 ;
  236.   DSBCAPS_CTRLPAN             = $00000040 ;
  237.   DSBCAPS_CTRLVOLUME          = $00000080 ;
  238.   DSBCAPS_CTRLDEFAULT         = $000000E0 ; { Pan + volume + frequency. }
  239.   DSBCAPS_CTRLALL             = $000000E0 ; { All control capabilities }
  240.  
  241.   DSSPEAKER_HEADPHONE         = 1 ;
  242.   DSSPEAKER_MONO              = 2 ;
  243.   DSSPEAKER_QUAD              = 3 ;
  244.   DSSPEAKER_STEREO            = 4 ;
  245.   DSSPEAKER_SURROUND          = 5 ;
  246.  
  247. function DirectSoundCreate ( lpGUID: PGUID; var lplpDS: IDirectSound;
  248.     pUnkOuter: IUnknown ): HRESULT ; stdcall ;
  249. function DirectSoundEnumerate ( lpCallback: LPDSENUMCALLBACK;
  250.     lpContext: Pointer ): HRESULT ; stdcall ;
  251.  
  252. implementation
  253.  
  254. function DirectSoundCreate ; external 'DSOUND' ;
  255. function DirectSoundEnumerate ; external 'DSOUND' name 'DirectSoundEnumerateA' ;
  256.  
  257. end.
  258.  
  259.